//
// Created by Administrator on 2024/1/31.
//
#include<vector>
#include<iostream>
using namespace std;

class Solution
{
public:
    int countHillValley(vector<int>& nums)
    {
        vector<int>nums_new{nums[0]};
        for (int i = 1; i < nums.size(); ++i)
        {
            if (nums[i]!= nums[i-1])
                nums_new.push_back(nums[i]);
        }
        // 求nums中峰和谷的个数
        // 注意峰和谷的定义
        int count = 0;
        for (int i = 1; i < nums_new.size() - 1; ++i)
        {
            if (nums_new[i] == nums_new[i - 1] || nums_new[i] == nums_new[i + 1]) continue;
            if (nums_new[i] < nums_new[i - 1] && nums_new[i] < nums_new[i + 1]) count++;
            if (nums_new[i] > nums_new[i - 1] && nums_new[i] > nums_new[i + 1]) count++;
        }
        return count;
    }
};

int main()
{
    Solution solution;
    vector<int> nums{2, 4, 1, 1, 6, 5};
    cout << solution.countHillValley(nums) << endl;
    return 0;
}
